﻿/**
 * 初始化页面
 */
function initPage() {
    win.crebtn('addWindow_btnCancel', '关闭', win.close);
    win.crebtn('addWindow_btnSave', '保存', addModule);
    document.getElementById("MODULE_NAME").focus();
    Validator.validate(document.getElementById(("addModuleForm")), 3);
}
/**
 *添加模块
 */
function addModule() {
    if (!Validator.validate(document.getElementById(("addModuleForm")), 4))
        return false;
    var orders = document.getElementById("ORDERS").value;
    var ordersall_sj = document.getElementById("ORDERSALL_SJ").value;
    var ordersall = ordersall_sj + "" + LPad(orders,'0',3);
    var json = {
        url:contextPath +"/server/sys/insertModule.do",
        msg:"数据保存中.....",
        form:"addModuleForm",
        params:{
            "SQLID":"module.insertModule",
            "ORDERSALL":ordersall
        },
        callback:[addModuleCallBack]
    };
    AjaxTools.ajax(json);
}
function addModuleCallBack(data) {
    var code = data.code;
    if (code == "0") {
        alert(data.msg);
        window.parent.parent.getModule();
        win.close('addWindow');
    } else {
        alert(data.msg);
    }

}
function onSelectModule(id, name,ordersall) {
    var selectedID = document.getElementById(id).value;
    win.open('ModuleTreeWindow', '模块树', '../../../admin/module/moduleTree.jsp?RTN_ID=' + id + "&RTN_NAME=" + name + "&RTN_ORDERSALL=" + ordersall + "&selectedID=" + selectedID, 250, 350, true, true, '', '', '', 'two');
}
